$(() => {
    // dom元素
    function append(time, title, price,url) {
        var span = "<a href="+url+"><span  class='gou'>" + time + "</span><span class='goumai'>" + title + "</span><span class='qian'>￥：" + price + "</span><div class='xian'></div></a>";
        $('#jubu').append(span)
    }

    function time(mm) {
        Date.prototype.toLocaleString = function () {
            return (
                this.getFullYear() +
                "." +
                (this.getMonth() + 1) +
                "." +
                this.getDate() 
            );
        };
        var unixTimestamp = new Date(mm);
        var commonTime = unixTimestamp.toLocaleString();
        return commonTime;
    };
    // 获取订单信息
    function go() {
        var fid = localStorage.getItem('fid');
        if (fid) {
            $.post('http://121.43.172.175/api/users/catrecord.html', {
                // $.post('http://192.168.0.125:8081/api/users/catrecord.html', {
                fid: fid
            }, (data) => {
                console.log(data);
                
                if (data.status == 1) {
                    /**
                     * title、url都是新增的字段，title取的是购买手机页面的商品title url对应的是这个商品的页面地址，点击一条订单就能够进入
                     */
                    var arr = data.data.orderRecordList;
                    for (let i = 0; i < arr.length; i++) {
                        var t = time(arr[i].createtime);
                        var title = arr[i].title;
                        var price = arr[i].price;
                        var url = arr[i].pageUrl;
                        append(t, title, price,url)
                    }
                } else {

                }

            })
        } else {}
    }
    go();
})